postgresql 设置只读用户

postgresql 设置只读用户

`
CREATE USER readonly WITH ENCRYPTED PASSWORD 'ropass';
alter user readonly set default_transaction_read_only=on;
GRANT USAGE ON SCHEMA public to readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly;

-- repeat code below for each database:

GRANT CONNECT ON DATABASE foo to readonly;
\c foo
GRANT USAGE ON SCHEMA public to readonly;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;

`

posted @ 2017-01-07 12:35  cutd  阅读(2597)  评论(0编辑  收藏  举报